#ifndef I_TO_STRING_H
#define I_TO_STRING_H

#include <string>
#include <algorithm>

std::string i_to_string(long long value)
{

	if ( value == 0LL )
		return std::string("0");

	// Pre-allocate space.
	std::string buf;
	buf.reserve( 100 ); 

	long long abs_value = value < 0LL ? -value: value;

	// Translating number to string with base:
	do 
	{
		buf += "0123456789"[ abs_value % 10LL ];
		abs_value /= 10LL;
	} while ( abs_value );

	// Append the negative sign
	if ( value < 0LL) buf += '-';

	std::reverse( buf.begin(), buf.end() );
	return buf;
}

#endif

